//获取实验室产品第二页的p，并改变相应内容,放大之后
function modifyIntr (parentNode, str) {
	for (var i = 0, child = parentNode.children; i < child.length; i++) {
		if (child[i].getAttribute("class") === "box2") {
			for (var j = 0, subChild = child[i].children; j < subChild.length; j++) {
				if(subChild[j].nodeName === "P") {
					subChild[j].innerHTML = str;
					subChild[j].style.textAlign = "left";
					subChild[j].style.margin = "0 20px";
			    }
		    }
	    }
	}
}

//鼠标离开之后，回到原来的样子,第二页的文字
function resotre (parentNode, str) {
	for (var i = 0, child = parentNode.children; i < child.length; i++) {
		if (child[i].getAttribute("class") === "box2") {
			for (var j = 0, subChild = child[i].children; j < subChild.length; j++) {
				if(subChild[j].nodeName === "P") {
					subChild[j].innerHTML = str;
					subChild[j].style.textAlign = "center";
					subChild[j].style.margin = "";
				}
			}
		}
	}
}

//第二页的放大镜特效
function zoom () {
	//鼠标放上去，整体放大，文本内容改变
	var lib = $(".library"),
		xiyouNav = $(".xiyouNav"),
		platform = $(".platform"),
		bp = $(".bP"),
		hatch = $(".hatch");

	var box1 = $$(".box1");

	lib.onmouseover = function  () {
		var content = "一个让西邮同学查询,续借等功能的网上图书馆",
			ele = box1[0];

		removeClass(ele, "restore")
		addClass(ele, "zoom");
		modifyIntr (lib, content);

		setTimeout(function  () {
			removeZoomLib();
		}, 1000);
	}


	//通用的remvoe放大
	function removeZoom (ele, newBox, oldBox) {
		removeClass(ele, "zoom");
		addClass(ele, "restore");
		resotre (newBox, oldBox);
	}

	function removeZoomLib () {
		var oriContent = "你身边的网上图书馆",
			ele = box1[0];

		removeZoom (ele, lib, oriContent);
	}

	// lib.onmouseout = function  () {
	// 	var oriContent = "你身边的网上图书馆",
	// 		ele = box1[0];

	// 	removeClass(ele, "zoom");
	// 	addClass(ele, "restore");
	// 	resotre (lib, oriContent);
	// }

	xiyouNav.onmouseover = function  () {
		var content = "无论你是技术宅,点击导航开启你精彩的大学生活",
			ele = box1[1];

		removeClass(ele, "restore")
		addClass(ele, "zoom");
		modifyIntr (xiyouNav, content);

		setTimeout(function  () {
			removeZoomShare();
		}, 1000);

	}

	// xiyouNav.onmouseout = function  () {
		
	// }

	function removeZoomShare (argument) {
		var oriContent = "享你所想，导你所需",
			ele = box1[1];

		removeZoom (ele, xiyouNav,oriContent);
	}

	
	platform.onmouseover = function  () {
		var content = "基于微信平台,为学生提供三大类综合性校园服务",
			ele = box1[2];

		removeClass(ele, "restore")
		addClass(ele, "zoom");
		modifyIntr (platform, content);

		setTimeout(function  () {
			removeZoomWeiChart ();
		}, 1000);

	}

	function removeZoomWeiChart () {
		var oriContent = "最懂你的微信平台",
			ele = box1[2];

		removeZoom (ele, platform, oriContent);
	}

	platform.onmouseout = function  () {
		
	}

	bp.onmouseover = function  () {
		var content = "不需要登录注册即可上传文件至云端,便捷收录文档",
			ele = box1[3];

		removeClass(ele, "restore")
		addClass(ele, "zoom");
		modifyIntr (bp, content);
		setTimeout(function () {
			removeZoomBP();
		}, 1000)
	}

	function removeZoomBP () {
		var oriContent = "化繁为简，畅享云端",
			ele = box1[3];

		removeZoom (ele, bp, oriContent);
	}

	// bp.onmouseout = function  () {
	// 	var oriContent = "化繁为简，畅享云端",
	// 		ele = box1[3];

	// 	removeClass(ele, "zoom");
	// 	addClass(ele, "restore");
	// 	resotre (bp, oriContent);
	// }

	hatch.onmouseover = function  () {
		var ele = box1[4];

		removeClass(ele, "restore")
		addClass(ele, "zoom");
		
		setTimeout(function () {
			removeZoomHatch ()
		}, 1000);
	}

	function removeZoomHatch () {
		var oriContent = "你身边的网上图书馆",
			ele = box1[4];

		removeClass(ele, "zoom");
		addClass(ele, "restore");
	}



	// hatch.onmouseout = function  () {
		
	// }
}

//产品底下的文字移入效果
function fontMoveIn () {
	var introduction = $$(".introduction"),
		intr = $(".intr"),
		newIntr = $$(".newIntr");

	//这里只设置了移入文字的居中效果，其他行为代码在main.css文件中
	for (var i = 0; i < introduction.length; i++) {
		(function  (i) {
			introduction[i].onmouseover = function  () {
		        newIntr[i].style.left = (introduction[i].offsetWidth - 
		        	                     newIntr[i].offsetWidth)/2 + "px";
	        }
		})(i);
	}
}